package org.csu.small.controller.admin;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.csu.small.common.Constant;
import org.csu.small.common.ResponseCode;
import org.csu.small.common.UniformResponse;
import org.csu.small.entity.Product;
import org.csu.small.entity.User;
import org.csu.small.service.IOrderService;
import org.csu.small.service.IProductService;
import org.csu.small.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.math.BigInteger;

/**
 * @author SongYaolun
 * @version 1.0
 * @date 2020/7/4 15:31
 */
@Controller
@RequestMapping("/manage/order/")
@Api(value = "API - AOrderController", description = "后台订单模块接口详情")
public class AOrderController {

    @Autowired
    private IOrderService orderService;

    @GetMapping("list")
    @ResponseBody
    @ApiOperation(value = "管理员获取订单详情")
    public UniformResponse list(
            @RequestParam(name = "current", defaultValue = "1") int current,
            @RequestParam(name = "size" , defaultValue = "5") int size)
    {
        return orderService.manageList(current,size);
    }

    @GetMapping("detail")
    @ResponseBody
    @ApiOperation(value = "管理员获取订单详情")
    public UniformResponse<OrderVo> getOrderDetail(BigInteger orderNo){
        return orderService.manageDetail(orderNo);
    }

    @PostMapping("send")
    @ResponseBody
    @ApiOperation(value = "后台发货")
    public UniformResponse<String> sene(BigInteger orderNo){
        return orderService.manageSendGoods(orderNo);
    }


    @GetMapping("search")
    @ResponseBody
    @ApiOperation(value = "后台管理员查询")
    public UniformResponse<Object> search(
            @RequestParam(name = "orderNo",required = false) BigInteger orderNo,
            @RequestParam(name = "productName",required = false) String productName,
            @RequestParam(name = "pageNum", defaultValue = "1") int pageNum,
            @RequestParam(name = "size" , defaultValue = "5") int size,
            @RequestParam(name = "status",required = false) int status)
    {

        return orderService.getOrderSearch(orderNo,productName,pageNum,size,status);
    }
}
